// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'
import ElementUI from 'element-ui'
import store from './store/main'

Vue.use(ElementUI)

Vue.config.productionTip = false
/*全局封装*/
Vue.prototype.$axios = axios;

//注册全局钩子用来拦截导航
router.beforeEach((to,from,next)=>{
  next();
  if (to.path.substr(0, 6) === '/index'){
    store.dispatch('getModulePath',to.path);
  }
})
/*router.beforeEach((to,from,next)=>{
  //获取store里面的token
  let token = store.state.token;
  //判断要去的路由有没有拦截
  if(to.meta.require) {
    if (token) {
      next();
    }else{
      next({
        path:'/login'
      })
    }
  }else{
    next();
  }
})*/

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
